package com.jianbing.zuixia.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.zuixia.domain.ZuixiaCheckpointRecord;
import com.jianbing.zuixia.service.IZuixiaCheckpointRecordService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 闯关记录，记录用户的闯关信息Controller
 * 
 * @author windbless
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/zuixia/chuanguan")
public class ZuixiaCheckpointRecordController extends BaseController
{
    @Autowired
    private IZuixiaCheckpointRecordService zuixiaCheckpointRecordService;

    /**
     * 查询闯关记录，记录用户的闯关信息列表
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZuixiaCheckpointRecord zuixiaCheckpointRecord)
    {
        startPage();
        List<ZuixiaCheckpointRecord> list = zuixiaCheckpointRecordService.selectZuixiaCheckpointRecordList(zuixiaCheckpointRecord);
        return getDataTable(list);
    }

    /**
     * 导出闯关记录，记录用户的闯关信息列表
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:export')")
    @Log(title = "闯关记录，记录用户的闯关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZuixiaCheckpointRecord zuixiaCheckpointRecord)
    {
        List<ZuixiaCheckpointRecord> list = zuixiaCheckpointRecordService.selectZuixiaCheckpointRecordList(zuixiaCheckpointRecord);
        ExcelUtil<ZuixiaCheckpointRecord> util = new ExcelUtil<ZuixiaCheckpointRecord>(ZuixiaCheckpointRecord.class);
        util.exportExcel(response, list, "闯关记录，记录用户的闯关信息数据");
    }

    /**
     * 获取闯关记录，记录用户的闯关信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(zuixiaCheckpointRecordService.selectZuixiaCheckpointRecordByRecordId(recordId));
    }

    /**
     * 新增闯关记录，记录用户的闯关信息
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:add')")
    @Log(title = "闯关记录，记录用户的闯关信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZuixiaCheckpointRecord zuixiaCheckpointRecord)
    {
        return toAjax(zuixiaCheckpointRecordService.insertZuixiaCheckpointRecord(zuixiaCheckpointRecord));
    }

    /**
     * 修改闯关记录，记录用户的闯关信息
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:edit')")
    @Log(title = "闯关记录，记录用户的闯关信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZuixiaCheckpointRecord zuixiaCheckpointRecord)
    {
        return toAjax(zuixiaCheckpointRecordService.updateZuixiaCheckpointRecord(zuixiaCheckpointRecord));
    }

    /**
     * 删除闯关记录，记录用户的闯关信息
     */
//    @PreAuthorize("@ss.hasPermi('zuixia:chuanguan:remove')")
    @Log(title = "闯关记录，记录用户的闯关信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(zuixiaCheckpointRecordService.deleteZuixiaCheckpointRecordByRecordIds(recordIds));
    }
}
